package com.walle.concurrenttest.pattern.readwritelock;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.pattern.readwritelock
 * @Description: ${todo}
 * @date 2019/2/20 14:30
 */
public class ReadWriteLockTest {

    public static void main(String[] args) {
        Data data = new Data(10);
        Thread reader1 = new Thread(new ReadThread(data));
        Thread reader2 = new Thread(new ReadThread(data));
        Thread reader3 = new Thread(new ReadThread(data));
        Thread reader4 = new Thread(new ReadThread(data));

        Thread writer1 = new Thread(new WriteThread(data,"123456"));
        Thread writer2 = new Thread(new WriteThread(data,"ABCDEF"));

        reader1.setName("reader1");
        reader2.setName("reader2");
        reader3.setName("reader3");
        reader4.setName("reader4");

        writer1.setName("writer1");
        writer2.setName("writer2");

        reader1.start();
        reader2.start();
        reader3.start();
        reader4.start();

        writer1.start();
        writer2.start();
    }
}
